/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vmcs.controller.statePattern;

import vmcs.controller.statePattern.TransactionController;

/**
 *
 * @author Eileen
 */
class ChangeGiverState extends VmcsState {    
    ChangeGiverState(TransactionController fsm){
        this.m_fsm = fsm;
    }
    @Override
    public void OnSelectDrink() {
        System.out.println("ChangeGiverState::On Select drink");
        //get change or refund
        int cost = m_fsm.getRefundAmount();
        System.out.println("Refund cash = "+ cost);
        m_fsm.setContent("Nothing is selected");
        m_fsm.setPrice(0);
        m_fsm.setTotalInsertedValue(0);
        m_fsm.setDrinkSelection(null);
        m_fsm.setActivateDrinkPanel(true);
    }    
    @Override
    public void OnTerminate() {
        System.out.println("ChangeGiverState::On terminate");
        m_fsm.setContent("Nothing is selected");
        m_fsm.setPrice(0);
        m_fsm.setTotalInsertedValue(0);
        m_fsm.setDrinkSelection(null);
        m_fsm.setActivateCoinPanel(false);
        m_fsm.setActivateDrinkPanel(false);
        m_fsm.getState(TransactionController.TERMINATE).OnTerminate();
    }    
    @Override
    public void OnGiveChange() {
        System.out.println("ChangeGiverState::On give change");
        double refund = m_fsm.getRefundAmount();
        System.out.println("Refund cash = "+ refund);
        //Call coin Store to update the numbers of coin left
        m_fsm.setContent("Nothing is selected");
        m_fsm.setPrice(0);
        m_fsm.setTotalInsertedValue(0);
        m_fsm.setDrinkSelection(null);
        m_fsm.setActivateDrinkPanel(true);
        m_fsm.changeState(TransactionController.DRINK_SEL);
    }    
    @Override
    public void OnDispenseDrink() {
        System.out.println("ChangeGiverState::On dispense drink! This satte is invalid --> throw exception!");
        
    }
    @Override
    public void OnMaintenance() {
        System.out.println("ChangeGiverState::On Maintenance mode");
        System.out.println("ChangeGiverState::On give change");
        double refund = m_fsm.getRefundAmount();
        System.out.println("Refund cash = "+ refund);
        //Call coin Store to update the numbers of coin left
        m_fsm.setContent("Nothing is selected");
        m_fsm.setPrice(0);
        m_fsm.setTotalInsertedValue(0);
        m_fsm.setDrinkSelection(null);
        m_fsm.getState(TransactionController.MAINT).OnMaintenance();
    }
    @Override
    public void OnReceiveCoin() {
        System.out.println("ChangeGiverState::On Receive Coin! This state is invalid --> throw exception!");
    }
    @Override
    public void OnStoreCoin() {
        System.out.println("ChangeGiverState::On Receive Coin");
    }
}

